package com.scientific.research.gobang.controller;

import com.scientific.research.gobang.pojo.User;
import com.scientific.research.gobang.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RequestMapping("User")
@RestController//Rest是让所有方法的返回值都是JSON格式
public class UserController {

    @Resource(name = "userServiceImpl")
    UserService userService;

    //注册
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("Register")
    public String Register(@RequestBody User newuser) {
        return userService.Register(newuser);
    }

    //查看其它用户信息
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("GetLookOtherUser")
    public User GetLookOtherUser(@RequestBody String email) {
        return userService.GetLookOtherUser(email);
    }

    //保存用户信息
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("SaveUserMessage")
    public Map SaveUserMessage(@RequestBody User saveUser) {
        return userService.SaveUserMessage(saveUser);
    }

    //登录验证
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("LoginVerify")
    public Map LoginVerify(@RequestBody User user) {
        return userService.LoginVerify(user);
    }

    //用于找回密码时的最后的提交验证
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("SubmitChangePassword")
    public Map SubmitChangePassword(@RequestBody Map jsonResponse) {
        return userService.SubmitChangePassword(jsonResponse);
    }

    //验证用户输入的邮箱的有效性
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("EmailVerify")
    public Map EmailVerify(@RequestBody Map jsonResponse) {
        return userService.EmailVerify(jsonResponse);
    }

    //发送邮箱，并保存相关信息
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("SendEmail")
    public void SendEmail(@RequestBody User user) {
        userService.SendEmail(user);
    }

    // 查看用户信息
    @SuppressWarnings("AlibabaLowerCamelCaseVariableNaming")
    @RequestMapping("LodeUserMessage")
    public User LodeUserMessage(@RequestBody Map<String, String> map) {
        return userService.LodeUserMessage(map);
    }
}
